<template>
	<view class="container">
		<!-- 提示信息 -->
		<view class="greenPic">
			<view class="font" @click="login">注册</view>
			<view class="h4">账号密码登录</view>
		</view>

		<view class="white">
			<view id="account" style="margin-top: 30px;margin-left: 20px;">
				<view class="account">
					<text style="margin-left: 1px;margin-top: 5px;">账号</text>
					<input style="margin-left: 15px;" type="number" placeholder="请输入手机号码" v-model="account" />
				</view>
				<view class="line" style="margin-top: -10px;"></view>
				<view class="pass">
					<text>密码</text>
					<input style="margin-left: 15px;" type="password" placeholder="请输入密码" v-model="password" />
				</view>
				<view class="lineTwo" style="margin-top: -15px;"></view>

				<view id="xieyi" class="checkbox-container" style="margin-top: 25px;margin-left: 9px;">
					<label>
						<checkbox :checked="checkboxValue" @change="handleCheckboxChange"></checkbox>
						<text>我已同意</text>
						<text style="color: #00C8AA;">问诊协议</text>
					</label>
				</view>
			</view>

			<view style="margin-top: 25px;" id="enter" @click="enter">
				<text>登录</text>
			</view>
		</view>

		<view class="threeEnter">第三方登录</view>
		<view class="enterImg">
			<image src="/static/wx.png" mode="" @click="goToWxPage"></image>
		</view>

		<view class="all">
			@版权归大喇叭编程实训基地所有
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		onMounted
	} from "vue";

	// 定义响应式变量
	const account = ref("");
	const password = ref("");
	const checkboxValue = ref(false);

	// 页面加载时检查是否已登录
	// 页面加载时检查是否已登录
	onMounted(() => {
		const storedUser = uni.getStorageSync("personMsg"); // 获取存储的用户信息
		if (storedUser) {
			// 如果已存储用户信息，直接跳转到主页
			uni.redirectTo({
				url: "/pages/home/home",
			});
		}
	});
	// 跳转到注册页面
	const login = () => {
		uni.reLaunch({
			url: "/pages/register/register",
		});
	};

	
	// 登录操作
	const enter = () => {
		uni.showToast({
			title: "请使用微信授权登录",
			icon: "none",
			duration: 2000,
		});
	};

	// 跳转到微信页面
	const goToWxPage = () => {
		uni.reLaunch({
			url: "/pages/wx/wx",
		});
	};
</script>

<style scoped>
	.container {
		background-color: #ffffff;
		width: 100%;
		height: 100vh;
		margin: 0;
		padding: 0;
	}

	/* 样式修改 */
	.checkbox-container {
		display: flex;
		align-items: center;
		margin-left: 5%;
	}

	.checkbox-container uni-checkbox {
		margin-right: 10px;
	}

	.checkbox-container text {
		font-size: 16px;
		color: #333;
	}

	.greenPic {
		background-color: #00c8aa;
		width: 100%;
		height: 13.625rem;
		position: relative;
	}

	.font {
		margin-left: 87%;
		font-size: 21px;
		padding-top: 12%;
		color: white;
		white-space: nowrap;
	}

	.h4 {
		text-align: center;
		font-size: 28px;
		color: white;
		white-space: nowrap;
	}

	.white {
		height: auto;
		width: 92%;
		margin-left: 4%;
		border-radius: 10px;
		box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
		margin-top: -50px;
		position: absolute;
		z-index: 10;
		background-color: white;
	}

	.account {
		width: 90%;
		margin: 10px 5%;
		height: 45px;
		display: flex;
		align-items: center;
	}

	.pass {
		width: 90%;
		margin: 5% 5%;
		height: 45px;
		display: flex;
		align-items: center;
	}

	.line,
	.lineTwo {
		width: 80%;
		height: 0.5px;
		background-color: #e5e5e5;
		margin-left: 5%;
	}

	#enter {
		width: 80%;
		height: 42px;
		line-height: 42px;
		border-radius: 20px;
		margin: 10px 10%;
		background-color: #00c8aa;
		text-align: center;
		margin-top: 62px;
	}

	#enter text {
		margin-left: -13px;
		position: absolute;
		color: white;
	}

	.threeEnter {
		margin-top: 93%;
		text-align: center;
		color: #adadad;
	}

	.enterImg {
		text-align: center;
		margin-top: 5%;
	}

	.enterImg image {
		width: 50px;
		height: 50px;
	}

	.all {
		position: absolute;
		margin-top: 5%;
		text-align: center;
		width: 100%;
		color: #adadad;
		font-size: 14px;
	}
</style>